package com.example.yoho.utils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/**
 * 自定义缓存拦截器
 * */
public class CatchInterceptor implements Interceptor {
    private String JSONStr="{\"msg\":\"yskyskysk\"}";
    @Override
    public Response intercept(Chain chain) throws IOException {
        Response response=null;//响应
        Request request=chain.request();//请求
        Response.Builder builder = new Response.Builder();
        builder.request(request);
        builder.code(200);
        builder.protocol(Protocol.HTTP_1_1);//请求协议
        builder.message("OK");
        ResponseBody body = ResponseBody.create(MediaType.parse("Content-Type: text/html"), JSONStr);
        builder.body(body);
        response=builder.build();
        return response;
    }
}
